package com.kcth.sylyg08.rest;

import com.kcht.adp.common.log.Logger;
import com.kcht.sylyg08.service.TagRecvBuffer;
import com.kcht.sylyg08.service.model.TagInfo;
import com.kcht.sylyg08.utils.XmlUtils;

import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.transaction.Transactional;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import java.util.List;

 /**
   *
   * @Package:        com.kcth.sylyg08.rest
   * @Description:    接收ale中间件发来的标签清点报文
   * @Author:         lenovo
   * @CreateDate:     2019/5/14 16:00
  *
  */
 /**
  *
  * 此接口会接入回归测试，测试五项，回归测试程序会查找以下日志内容，来确认服务正常
  * JoinQueue
  * LeaveQueue
  * TagEnterStation
  * ReportTagEnterStation
  * ReportTagLeaveStation
  * */
@Path("/rfid")
@RequestScoped
@Transactional(rollbackOn=Exception.class)
public class ReportReceiveServiceFacade {
    @Inject
    private Logger logger;

    @POST
    public String receiveXML(String message) {
        /** 接收报文，调用工具类解析xml */
        List<TagInfo> list = XmlUtils.parseXML(message);
        for (TagInfo tagInfo : list) {
            logger.info("接收到标签信息--->"+tagInfo.toString());
        }
        TagRecvBuffer.add(list);
        return "success";
    }

}
